clear


*** tobit test

set obs 1000

gen y=0

gen x=_n

gen e=10*runiform()*x/10

//replace e=100*runiform() if x<100

replace y=x-1000+e

replace y=0 if y<0

replace y=5 if y>5


tobit y x, ll(0) ul(2000)


predict yhat

replace yhat=0 if yhat<0

predict ystar, ystar(0, .)

replace ystar=0 if ystar==. // for really low values this gets missing

sum y*
